<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>新品有戏合作平台后台登录</title>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/boot.css">
    <style type="text/css">
        .login{width:400px;margin: 0 auto;margin-top: 200px;}
        .login .panel-title{text-align: center;}
        .input-group{margin-bottom: 20px}
        .code-text{width: 240px;float: left;}
        .code-img{float: right;border: 1px solid #ccc;margin: 1px 10px 0 0;}
        .footer{line-height: 35px;width: 300px;margin: 0 auto;margin-top:10px;border-radius:10px;background: rgba(50,50,50,0.6);color:#fff;}
    </style>
</head>
<body>
<div class="panel panel-default login">
    <div class="panel-heading">
        <h3 class="panel-title">新品有戏商家合作平台登陆</h3>
    </div>
    <div class="panel-body">
        <label style="display: none;color: red;text-align: center" id="info"></label>
        <form action="" method="post" onsubmit="return false" id="checklogin">
            <div class="input-group">
                <span class="input-group-addon" id="sizing-addon2"><i class="fa fa-user-circle-o"></i> 账　号</span>
                <input type="text" name="username" id="username" class="form-control" aria-describedby="sizing-addon2">
            </div>
            <div class="input-group">
                <span class="input-group-addon" id="sizing-addon2"><i class="fa fa-key"></i> 密　码</span>
                <input type="password" id="password" name="password" class="form-control" aria-describedby="sizing-addon2">
            </div>
            <div class="input-group code-text">
                <span class="input-group-addon" id="sizing-addon2"><i class="fa fa-barcode"></i> 验证码</span>
                <input type="text" id="code" name="code" class="form-control" aria-describedby="sizing-addon2">
            </div>

            <div class="code-img">
                <img src="{:url('index/index/code')}" id="imgs" onclick="this.src='{:url(\'index/index/code\')}?id='+Math.random()" width="80px" height="30px" alt="" >
            </div>
            <!-- 清除浮动，一删就乱！！！！！！！！ -->
            <div class="clearfix"></div>
            <button type="submit" id="login" class="btn btn-primary btn-block"><i class="fa fa-sign-in"></i> 登 陆 </button>
        </form>
    </div>
</div>
<script type="text/javascript" src="__STATIC__/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="__STATIC__/login/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>
<script>
    //检测浏览器的大小，对登录框的位置进行计算
    $(".login").css("margin-top",($(document).height()/2) - ($('.login').height()/2)-50);

    $("#login").click(function () {
        if(!$("#username").val()){
            $("#info").html('请填写用户名');
            $("#info").css('display','block');
            return;
        }
        if(!$("#password").val()){
            $("#info").html('请填写密码');
            $("#info").css('display','block');
            return;
        }
        if(!$("#code").val()){
            $("#info").html('请填写验证码');
            $("#info").css('display','block');
            return;
        }
        $.ajax({
            url:"{:url('index/index/adminlogin')}",
            data:$("#checklogin").serialize(),
            type:"post",
            dataType:"json",
            success:function (res) {
                if(res.success){
                    window.location.href="{:url('/index/examine/index')}";
                }
                if(res.error){
                    $("#info").html(res.error);
                    $("#info").css('display','block');
                    $("#imgs")[0].click();
                }
            }
        });
    });
</script>
</body>
</html>